<template>
  <div class="singleOrderView pd-20">
    <div class="detailView">
      <div class="detail"
           v-if="item.userDto">
        <div class="name">用户头像</div>
        <div class="value">
          <img :src="item.userDto.headImageUrl"
               alt="工作室头像"
               preview="bannerView"
               style="width: 100px;height:100px;border-radius: 50%">
        </div>
      </div>
      <div class="detail"
           v-if="item.userDto">
        <div class="name">用户</div>
        <div class="value">{{item.userDto.nickName}}</div>
      </div>
      <div class="detail">
        <div class="name">订单编号</div>
        <div class="value">{{item.orderNumber}}</div>
      </div>
      <div class="detail">
        <div class="name">订单名称</div>
        <div class="value">{{item.tradeName}}</div>
      </div>
      <div class="detail">
        <div class="name">医生</div>
        <div class="value">{{item.doctorDto?item.doctorDto.nickName:''}}</div>
      </div>
      <div class="detail">
        <div class="name">医生电话</div>
        <div class="value">{{item.doctorDto?item.doctorDto.loginName:''}}</div>
      </div>
      <div class="detail">
        <div class="name">金额</div>
        <div class="value">{{item.money}}元</div>
      </div>
      <div class="detail">
        <div class="name">剩余次数</div>
        <div class="value">{{item.effectiveCount}}次</div>
      </div>
      <div class="detail">
        <div class="name">合计次数</div>
        <div class="value">{{item.count}}次</div>
      </div>
      <div class="detail">
        <div class="name">订单类型</div>
        <div class="value">{{item.serviceType == 14?'一元问诊订单':'单次咨询问诊订单'}}</div>
      </div>
      <div class="detail">
        <div class="name">订单状态</div>
        <div class="value">{{item.orderStatus|orderStatus}}</div>
      </div>
      <div class="detail">
        <div class="name">支付订单号</div>
        <div class="value">{{item.payInfo}}</div>
      </div>
      <div class="detail">
        <div class="name">支付类型</div>
        <div class="value">{{item.payType|payType}}</div>
      </div>
      <div class="detail">
        <div class="name">支付时间</div>
        <div class="value">{{commonFunction.timestampFormat(new Date(item.paymentDate), 'yyyy-MM-dd hh:mm:ss')}}</div>
      </div>
      <p align="center"
         class="mt-20 goPage">
        <Button type="primary"
                @click="goPage">返 回</Button>
      </p>
    </div>
  </div>
</template>

<script>
  import { orderMgt } from '@/api/codeName'
  export default {
    name: "singleOrderView",
    data () {
      return {
        item: {},
      }
    },
    mounted () {
      this._getViewById()
    },
    methods: {
      _getViewById () {
        this.ajax({
          type: this.api.singleOrderView.type,
          url: this.api.singleOrderView.url,
          data: {
            id: this.$route.query.id
          },
          success: (data) => {
            this.item = data.object
            this.item.member = [this.item.member]
            this.$previewRefresh()
          },
          error: (data) => {
            this.$Message.error(data.message);
          }
        })
      },
      goPage () {
        this.$router.push({ name: 'singleOrderMgt' })
      }
    },
    filters: {
      orderType: (value) => {
        for (let i = 0; i < orderMgt.servicePageOrderMgt.orderType.length; i++) {
          if (value == orderMgt.servicePageOrderMgt.orderType[i].code) {
            return orderMgt.servicePageOrderMgt.orderType[i].name
          }
        }
        return value
      },
      orderStatus: (value) => {
        for (let i = 0; i < orderMgt.servicePageOrderMgt.orderStatus.length; i++) {
          if (value == orderMgt.servicePageOrderMgt.orderStatus[i].code) {
            return orderMgt.servicePageOrderMgt.orderStatus[i].name
          }
        }
        return value
      },
      payType: (value) => {
        for (let i = 0; i < orderMgt.servicePageOrderMgt.payType.length; i++) {
          if (value == orderMgt.servicePageOrderMgt.payType[i].code) {
            return orderMgt.servicePageOrderMgt.payType[i].name
          }
        }
        return value
      }
    }
  }
</script>

<style lang="scss" type="text/scss" rel="stylesheet/scss">
  .singleOrderView {
  }
  .goPage {
    padding-bottom: 20px;
  }
</style>
